from fastapi import FastAPI
from fastapi.middleware.cors import CORSMiddleware
from api.auth import router as auth_router
from api.chat import chat_router

app = FastAPI(
    title="Agno智能体",
    description="基于FastAPI与Agno的智能体API服务", 
)

# 添加CORS中间件
app.add_middleware(
    CORSMiddleware,
    allow_origins=["http://localhost:5173", "http://127.0.0.1:5173", "http://localhost:3000", "http://127.0.0.1:3000"],  # 前端开发服务器地址
    allow_credentials=True,
    allow_methods=["*"],
    allow_headers=["*"],
)

# 包含认证路由
app.include_router(auth_router, prefix="/api")
# 包含聊天路由
app.include_router(chat_router, prefix="/api")



@app.get("/", summary="首页")
async def index():
    return "Agno"


if __name__ == "__main__":
    import uvicorn

    print("🚀 启动服务器中...")
    uvicorn.run(
        "main:app",
        host="0.0.0.0",
        port=5050,
        log_level="info",
    )